template.defaults.imports.formatString = function(typestr, type) {

	if(type == 'notification') {
		if(typestr == 'order') {
			return '../images/ddxx.png'
		} else {
			return '../images/xtxx.png'
		}
	} else if(type == 'datestr') {
		var datetime = moment(typestr).format('YYYY-MM-DD HH:mm:ss');
		return datetime;
	} else if(type == 'condition') {
		if(typestr) {
			return typestr;
		} else {
			return '无'
		}

	} else {
		return typestr;
	}

}

template.defaults.imports.formatDate = function(datastr) {
	var datetime = moment(datastr).format('YYYY-MM-DD HH:mm:ss');
	return datetime;
}

template.defaults.imports.formatDateEndDate = function(datastr) {
	var datetime = moment(datastr).format('YYYY-MM-DD');
	return datetime;
}

template.defaults.imports.formatIntervalStart = function(datastr) {
	var datetime = moment(datastr).format('YYYY-MM-DD HH:mm');
	return datetime;
}

template.defaults.imports.formatIntervalEnd = function(datastr) {
	var datetime = moment(datastr).format('HH:mm');
	return datetime;
}

template.defaults.imports.formatHttpString = function(str) {
	return serverAddress + '/' + str.replace('client', '').replace(/\\/g, "/");
}
template.defaults.imports.formatDistance = function(distance) {
	return(distance / 1000).toFixed(2);
}

template.defaults.imports.formatStringLan = function(str, lan) {

	if($.getLength(str) > lan) {
		return $.cutstr(str, lan);
	} else {
		return str;
	}

}

var templateRegister = {

	common: {
		id: 'common',
		src: '../template/notification/common.tl'
	},
	ordera: {
		id: 'ordera',
		src: '../template/order/order_detail_a.tl'
	},
	orderb: {
		id: 'orderb',
		src: '../template/order/order_detail_b.tl'
	},
	orderc: {
		id: 'orderc',
		src: '../template/order/order_detail_c.tl'
	},
	orderd: {
		id: 'orderd',
		src: '../template/order/order_detail_d.tl'
	},
	orderDrugSpare: {
		id: 'orderDrugSpare',
		src: '../template/order/order_drug_spare.tl'
	},
	orderListEnd: {
		id: 'orderListEnd',
		src: '../template/order/order_list_end.tl',
		desc: '订单完成列表'
	},
	orderListConfim: {
		id: 'orderListConfim',
		src: '../template/order/order_list_confim.tl',
		desc: '订单完成列表'
	},
	orderListWait: {
		id: 'orderListWait',
		src: '../template/order/order_list_wait.tl',
		desc: '订单完成列表'
	},

	orderAddDrug: {
		id: 'orderAddDrug',
		src: '../template/order/order_add_drug.tl',
		desc: '订单完成列表'
	},
	orderAddSpare: {
		id: 'orderAddSpare',
		src: '../template/order/order_add_spare.tl',
		desc: '订单完成列表'
	},
	orderGrab: {
		id: 'orderGrab',
		src: '../template/order/order_grab.tl',
		desc: '抢单列表'
	},
	patientsList: {
		id: 'patientsList',
		src: '../template/set/set_patients_list.tl',
		desc: '抢单列表'
	},
	serviceList: {
		id: 'serviceList',
		src: '../template/set/set_service_list.tl',
		desc: '服务列表'
	},

}